The present disclosure relates to compiling source code in a computer system, and more specifically, to the manner in which a compiler provides stack space associated with passing parameters to a function when it is called and how a home memory location for a parameter passed in a register may be provided.
A function definition or prototype typically declares parameters in a parameter list between parentheses. For example, the function “func1” may be defined as: void func1 (int x, float y, long z). The parameters of func1 are x, y, and z. The parameters are of data type integral, float, and long, respectively. The term “parameter” may be used to refer to a variable named in the parenthesized parameter list and “argument” may be used to refer to a particular value that is used in a function call. However, those skilled in the art may refer to the value that is used in a function call as a parameter and may a variable as an argument, the intended meaning being clear from the context.
In the some programming languages, such as the C language, a function can have a variable number of arguments. A function that can have a variable arguments is referred to as a variadic function. A variadic function may be declared with an ellipsis as its last parameter, matching zero or more arguments on a call and indicating that the types and number of arguments may vary. An example of a variadic function is printf (int x, float y, . . . ).
An application binary interface (“ABI”) is the set of rules that must be followed by any interface between two program modules at the level of machine code. Among other things, an ABI defines how functions are called and how arguments are passed to functions, i.e., calling conventions. Every parameter has a data type. An ABI generally specifies how each of the various different data types is passed when a function is called. Generally, arguments can be passed in memory, registers, or a combination of memory and registers. Generally, an ABI may specify that a particular argument is to be passed in a register or a memory location. A compiler typically compiles source code according the rules and conventions specified in an ABI.